package com.example.isoftlangchainai.rag;

import dev.langchain4j.data.embedding.Embedding;
import dev.langchain4j.model.openai.OpenAiEmbeddingModel;
import dev.langchain4j.model.output.Response;

/**
 * @Description: 内容嵌入Embedding加强Embed
 * @Date :2025/7/16 9:42
 * @Author :chenjun
 */
public class ContextEmbeddingEmbedDemo {

    public static void main(String[] args) {
        //OpenAi嵌入模型EmbeddingModel
        OpenAiEmbeddingModel embeddingModel = OpenAiEmbeddingModel.builder()
                .baseUrl("http://langchain4j.dev/demo/openai/v1")
                .apiKey("demo")
                .modelName("text-embedding-3-small")
                .build();

        Response<Embedding> embed = embeddingModel.embed("你好，我叫Harrychenj");
        System.out.println(embed.content().toString());
        System.out.println(embed.content().vector().length);

    }
}
